package com.sgzn.sgpay.enums;

import lombok.Getter;

/**
 * Created by xxjs-gd-llf
 * DATETIME:2018/5/1 14:18
 * @author linliangfang
 * Description:
 */
public enum EnumLoginCheckResponseResult {
    /**
     * 成功
     */
    SUCCESS("success", "成功"),
    /**
     * 失败
     */
    FAILURE("failure", "失败"),
    /**
     * 未注册
     */
    UNREGISTER("unregister", "未注册");


    @Getter
    private String stateCode;
    @Getter
    private String stateDesc;

    /**
     * 构造函数
     * @param stateCode
     * @param stateDesc
     */
    EnumLoginCheckResponseResult(String stateCode, String stateDesc) {
        this.stateCode = stateCode;
        this.stateDesc = stateDesc;
    }

    /**
     * 根据业务编码码获取类型
     * @param stateCode
     * @return
     */
    public static String getDescByCode(String stateCode) {
        //一个temp代表 SIGN_AGENT_RECEIVE_TO_ACCOUNT("00000028","1", "签约代收入账")
        for (EnumLoginCheckResponseResult temp : EnumLoginCheckResponseResult.values()) {
            if (temp.stateCode.equals(stateCode)) {
                return temp.stateDesc;
            }
        }
        return stateCode+"UNKNOWN";
    }

    public static String getCodeByDesc(String stateDesc){
        for (EnumLoginCheckResponseResult test : EnumLoginCheckResponseResult.values() ){
            if( test.stateDesc.equals(stateDesc) ){
                return test.stateCode;
            }
        }
        return  stateDesc+"未定义";
    }
}
